<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="initial-scale=1.0, user-scalable=no, width=device-width">
    <title>设置点标注的文本标签</title>
    <link rel="stylesheet" href="http://cache.amap.com/lbs/static/main1119.css"/>
    <script src="http://webapi.amap.com/maps?v=1.3&key=e51bd3d35de6fe57218feaa7e579481f "></script>
    
    <script type="text/javascript" src="http://cache.amap.com/lbs/static/addToolbar.js"></script>
    <link rel="stylesheet" href="css/mui.min.css">
	<script src="js/mui.min.js"></script>
</head>
<body>
<div id="container"></div>
<div id="test">
	
</div>
<div id="tip" class="tip" style="float: left;margin-top: 310px;right: 190px;display: none;" ></div>
<script>
			var sessionid="1";
	        var proVersion = "1.0";
	        var accountid="216";
	        var vclId="154719";
	        var keySta = "1";
	        var vclNum="";
			var keySta="";
			var lng ="";
			var lat ="";
			var posTime ="";
			var vclSpd ="";
			var vclDrct="";
			
    function test(){
    	window.location.href="index.html";
    }
    var map = new AMap.Map('container', {
        resizeEnable: true,
        center: [116.397428, 39.90923],
        zoom: 5
    });
/*    var marker = new AMap.Marker({
    	//icon:'sa.png',
        position: [112,38]
    });*/
   // marker.setMap(map);
   // marker2.setMap(map);
    // 设置鼠标划过点标记显示的文字提示
  //  marker.setTitle('我是marker的title');

    // 设置label标签
  //  marker.setLabel({//label默认蓝框白底左上角显示，样式className为：amap-marker-label
   //     offset: new AMap.Pixel(20, 20),//修改label相对于maker的位置
   //     content: "我是marker的label标签"
   // });
/*       marker.on('click', function() {
       	 var lnglat = new AMap.LngLat(116, 38);
       	 
    	map.setCenter(marker.getPosition());
    	document.getElementById("tip").style.display="";*/
        //alert('您点击了点');
       // marker.setLabel({
        //	 offset: new AMap.Pixel(-20, -20),//修改label相对于maker的位置
       		// content: document.getElementById("tip").innerHTML
        //});
   // });
    
    /*function show(){
    	 marker.setLabel({
        	 offset: new AMap.Pixel(-40, -40),//修改label相对于maker的位置
       		 content: "点击弹出框标签后的效果"
        });
    }*/
    var lineArr = [
        [116.368904, 39.913423],
        [116.382122, 39.901176],
        [116.387271, 39.912501],
        [116.398258, 39.904600]
    ];
    var polyline = new AMap.Polyline({
        path: lineArr,          //设置线覆盖物路径
        strokeColor: "#3366FF", //线颜色
        strokeOpacity: 1,       //线透明度
        strokeWeight: 5,        //线宽
        strokeStyle: "solid",   //线样式
        strokeDasharray: [10, 5] //补充线样式
    });
    polyline.setMap(map);
   //  getautoMap();
			//function getautoMap(){
				mui.ajax('http://222.223.231.137:8008/IEMS_APP_IOSG/APP/vclMapList',{          
				data:{param:'{"proVersion":"'+proVersion+'","accountId":"'+accountid+'","sessionid":"'+sessionid+'","data":{"vclId":"'+vclId+'","keySta":"'+"0"+'"}}'},
				dataType:'jsonp',//服务器返回json格式数据
				type:'post',//HTTP请求类型
				timeout:1000000,//超时时间设置为10秒；
				
				success:function(data){
					var jsonObj = window.JSON.parse(data);
						var resultdata = jsonObj.data;
					if(jsonObj.resultCode=="1"){
						
					if(vclId!=null||vclId!=""){//单设备
							lng=resultdata[0].lng;
							lat=resultdata[0].lat;
							keySta=resultdata[0].keysta;
							vclNum=resultdata[0].vclnum;
							posTime=resultdata[0].postime;
							vclSpd=resultdata[0].vclspd;
							/*var myIcon = new AMap.Icon("http://api.map.baidu.com/img/markers.png", new AMap.Size(23, 25), {  
                        	offset: new AMap.Size(10, 25), // 指定定位位置  
                        	imageOffset: new AMap.Size(0, 0 - 10 * 25) // 设置图片偏移  
                   			 });  */
							var marker = new AMap.Marker({
						    	icon:'images/drawable-hdpi/arrow_green.png',
						    	//icon:myIcon,
						        position: [lng,lat]
						    });
						    if(keySta=1){//开机
								marker.setIcon("images/drawable-hdpi/arrow_green.png");
							}else{
								marker.setIcon("images/drawable-hdpi/arrow_red.png");
							}
						    marker.setMap(map);
							//var marker = new AMap.Marker();
							//marker.setIcon("images/drawable-hdpi/arrow_green.png");
							//var marker=new plus.maps.Marker(new plus.maps.Point(lng,lat));
							
							
							marker.setLabel("默认的lable");
							
							 marker.on('click', function() {
       	 						var lnglat = new AMap.LngLat(lng,lat);
    							map.setCenter(marker.getPosition());
    							document.getElementById("tip").style.display="";
    							document.getElementById("tip").innerHTML=vclNum +"<br/>时间："+posTime+"<br/>车速："+vclSpd+
    							"<br/><button onclick='gotoguiji()'>轨迹</button>"
    							+"<button onclick='gotosinglevclfile()'>单车信息</button><br/>"
    							;
    						});
    						
							//var bubble = new plus.maps.Bubble(lable);
							//marker.setBubble(bubble);
							//map.addOverlay(marker);
							//map.setCenter(new plus.maps.Point(lng,lat));
						}else {//多设备
							for(var i=0;i<resultdata.length;i++){
								lng=resultdata[i].lng;
								lat=resultdata[i].lat;
								keySta=resultdata[i].keysta;
								vclNum=resultdata[i].vclnum;
								posTime=resultdata[i].postime;
								vclSpd=resultdata[i].vclspd;
								var marker=new plus.maps.Marker(new plus.maps.Point(lng,lat));
							if(keySta=1){//开机
								marker.setIcon("../../images/drawable-hdpi/arrow_green.png");
							}else{
								marker.setIcon("../../images/drawable-hdpi/arrow_red.png");
							}
							marker.setLabel(vclNum);
							var lable=vclNum+"\n"+"位置:"+"/n"+"时间:"+posTime+"\n"+"车速:"+vclSpd;
							var bubble = new plus.maps.Bubble(lable);
							marker.setBubble(bubble);
							map.addOverlay(marker);
							mui.toast(vclNum);
							map.centerAndZoom(new plus.maps.Point(116.3977,39.906016),4);
							}
						}
					}else{
					}
					
				},error: function(xhr, type, errorThrown) {
						}
			});
		//}
		
	function gotoguiji(){//轨迹
    	window.location.href="vcltrack.html?sessionid="+sessionid+"&proVersion="+proversion+"&accountId="+accountid+"&vclId="+vclId+"&bgnTime="+bgnTime+"&endTime="+endTime;
    }
    function gotosinglevclfile(){//单车信息
    	window.location.href="pages/singfile/singlevclfile.html?sessionid="+sessionid+"&proVersion="+proversion+"&accountId="+accountid+"&vclid="+vclId;
    }
  /* function gotosinglevclfile(){
    	window.location.href="pages/singfile/vclworkreortlog.html.html?sessionid="+sessionid+"&proVersion="+proversion+"&accountId="+accountid+"&vclid="+vclId;
    }*/
</script>
</body>
</html>